<script setup>
import {getStudentEvaluate} from "/src/api/hbmy_wx/StudentEvaluateService";
import Header from "/@/components/Header/Header.vue";
import EvaluateIndex from "/@/views/studentEvaluate/EvaluateIndex.vue";
const evaluateCoursesList = ref([])
const activeName = ref([])
const collapseRef = ref(null)
const value = ref()
const TotalInfoPage = ref(true)
const courseNeedEvaluate = ref({})
const goToEvaluateInfo = (course) => {
  TotalInfoPage.value = false
  courseNeedEvaluate.value = course
}
const getCourseList = async () => {
  const res = await getStudentEvaluate()
  evaluateCoursesList.value = JSON.parse(res.response.value.extend.courses)
}
onMounted(async () => {
  await getCourseList()
})
// Watch for changes in scoreArray
watch(TotalInfoPage, async (newTotalInfoPage) => {
  await getCourseList()
});
</script>

<template>
  <div v-if="TotalInfoPage">
    <Header title="学生评教"></Header>
    <div class="content" style="margin: 5px 10px;">
      <van-collapse v-model="activeName" ref="collapseRef">
        <van-collapse-item
            v-for="course in evaluateCoursesList"
            :name="course.tcId"
            :is-link="false"
            :readonly="true"
            size="large">
          <template #title>
            {{course.courseName}}
            <!--          <strong>{{course.courseName}}</strong>-->
          </template>
          <template #value>
            <van-row justify="end" gutter="10">
              <van-col>
                <div v-if="course.hasEvaluation === 1" style="color: #07C160" >已评教</div>
                <van-tag v-else type="primary" plain size="large" @click="goToEvaluateInfo(course)">评教</van-tag>
              </van-col>
            </van-row>
          </template>
        </van-collapse-item>
      </van-collapse>
    </div>
  </div>
  <EvaluateIndex v-else v-model="TotalInfoPage" :title="courseNeedEvaluate.courseName" :course-info="courseNeedEvaluate"></EvaluateIndex>

</template>

<style scoped lang="less">

</style>
